Ext.define('TS.controller.Movie', {
	extend: 'Ext.app.Controller',

	models: [// TODO zgrupowac słowniki z kodami (do słownika)
		'Movie'
	],
	stores: [
	    'Movie'
	],
	views: [
		'movie.Panel'
	],
	
	init: function() {
		this.control({
			'viewport > tabpanel' : {
               render: this.onStart,
               tabchange:this.onShow
            }
		});
	},
	
	onStart:function(tabpanel,x){
		tabpanel.add({xtype:'moviepanel'});
	},
	
	onShow:function(tabpanel,tab){

		if(tab.xtype=='moviepanel' && tab.items.length==0){
			
			Util.require([
				'movie.Form','movie.Grid'
			],function(){
				tab.add(
					Factory.layout.duoTab('Filmy','movie')
				);
				Util.s.fillEach(
					Dict.movie,Dict.author,Dict.language,Dict.tag
				);
				
			},'TS.view.movie');			
		};
	},
	
	util:{
		
	}
});